import { RobCityStepPanelBase } from "../RobCityStepPanelBase";
import { ObjCreate } from "../../common/ObjCreate";
import { ImagesConst } from "../../../resource/ImagesConst";
import { ResFileConst } from "../../../resource/ResFileConst";
import { GlobalStyle } from "../../../../common/global/GlobalStyle";
import { Language } from "../../../../../extend/language/Language";
import { FilterConst } from "../../../../component/gconst/FilterConst";
import { ItemsBox } from "../../common/item/ItemsBox";
import { CopyConfig } from "../../../resource/CopyConfig";
import { RuleExplainButton } from "../../common/button/RuleExplainButton";
import { GTextFormat } from "../../../../common/GTextFormat";
import { FontUtil } from "../../../../common/font/FontUtil";
import { RobCityStepTwoTeamRenderer } from "./RobCityStepTwoTeamRenderer";
import { DataProvider } from "../../../../../fl/data/DataProvider";
import { Dispatcher } from "../../../../mvc/core/Dispatcher";
import { DataEvent } from "../../../events/DataEvent";
import { EventName } from "../../../mvc/EventName";
import { ECopyType } from "../../../../../Message/Public/ECopyType";
import { GTileList } from "../../../../../com/mui/controls/GTileList";
import { Cache } from "../../../cache/Cache";
import { ClockManager } from "../../../manager/ClockManager";
import { GLoadedButton } from "../../../../../com/mui/controls/GLoadedButton";
import { GTextFiled } from "../../../../../com/mui/controls/GTextFiled";
import { SecTimerView } from "../../common/SecTimerView";
type int = number;
//class RobCityStepTwoPanel
    
    export  class RobCityStepTwoPanel extends RobCityStepPanelBase
    {
        constructor()
        {
            super();
            this._groupDic = new Map<any, any> /* flash.utils.Dictionary */();
            this._groupDpDic = new Map<any, any> /* flash.utils.Dictionary */();
            this.initUI();
            return;
        }

        /* internal  */initUI(): void
        {
            ObjCreate.createBg(0, 0, 804, 160, this);
            ObjCreate.createGImageBitmap(ImagesConst.RobCityBg2, 1, 2, this);
            ObjCreate.createBg(0, 163, 804, 223, this);
            ObjCreate.createBg(8, 170, 193, 209, this, ImagesConst.DisabledBg);
            ObjCreate.createBg(206, 170, 193, 209, this, ImagesConst.DisabledBg);
            ObjCreate.createBg(404, 170, 193, 209, this, ImagesConst.DisabledBg);
            ObjCreate.createBg(602, 170, 193, 209, this, ImagesConst.DisabledBg);
            this._enterBtn = ObjCreate.createGLoadedButton(ResFileConst.RobCityEnterCopyBtn, 352, 50, 100, 33, this);
            this._enterBtn.addEventListener(flash.events.MouseEvent.CLICK, this.onEnterBtnClickHandler);
            var loc1=GlobalStyle.getTextFormatCenter(GlobalStyle.textFormat5);
            this._tipLabel = ObjCreate.createGTextField("", 200, 92, 404, 20, this, loc1, false);
            this._tipLabel.htmlText = Language.getString(60939);
            this._countDown = ObjCreate.createSecTimeView("", 200, 115, 404, 20, this, loc1);
            this._countDown.filters = [FilterConst.glowFilter];
            this._countDown.mouseEnabled = false;
            var loc2=new ItemsBox();
            loc2.x = 58;
            loc2.y = 114;
            loc2.setItems(CopyConfig.instance.getRobCopyRewards(2));
            this.addChild(loc2);
            var loc3=new ItemsBox();
            loc3.x = 622;
            loc3.y = 114;
            loc3.setItems(CopyConfig.instance.getRobCopyRewards(3));
            this.addChild(loc3);
            this.addList(1, 8, 170);
            this.addList(2, 206, 170);
            this.addList(3, 404, 170);
            this.addList(4, 602, 170);
            var loc4;
            (loc4 = new RuleExplainButton()).tooltipText = CopyConfig.instance.getRobCopyDesc(4);
            loc4.x = 490;
            loc4.y = 130;
            this.addChild(loc4);
            return;
        }

        /* internal  */addList(arg1: int, arg2: int, arg3: int): void
        {
            var loc1=new GTextFormat(FontUtil.stXingkaiName, 24, 16776960, null, null, null, null, null, flash.text.TextFormatAlign.CENTER);
            var loc2;
            (loc2 = ObjCreate.createGTextField("", arg2, arg3 + 5, 193, 30, this, loc1, false)).htmlText = Language.getStringByParam(60934, arg1);
            var loc3;
            (loc3 = ObjCreate.createTileList(arg2, arg3 + 37, 193, 180, this)).rowHeight = 28;
            loc3.columnWidth = 190;
            loc3.setStyle("cellRenderer", RobCityStepTwoTeamRenderer);
            this.addChild(loc3);
            this._groupDic[arg1] = loc3;
            this._groupDpDic[arg1] = new DataProvider();
            return;
        }

        /* internal  */onEnterBtnClickHandler(arg1: Object /* flash.events.Event */): void
        {
            Dispatcher.dispatchEvent(new DataEvent(EventName.RobCity_doEnterCopy, ECopyType._ECopyRobCityTwo));
            return;
        }

        public updateGroupLists(arg1: Array<any>, arg2: Array<any>, arg3: Array<any>, arg4: Array<any>): void
        {
            (this._groupDpDic[1] as DataProvider).removeAll();
            (this._groupDpDic[2] as DataProvider).removeAll();
            (this._groupDpDic[3] as DataProvider).removeAll();
            (this._groupDpDic[4] as DataProvider).removeAll();
            (this._groupDpDic[1] as DataProvider).addItems(arg1);
            (this._groupDpDic[2] as DataProvider).addItems(arg2);
            (this._groupDpDic[3] as DataProvider).addItems(arg3);
            (this._groupDpDic[4] as DataProvider).addItems(arg4);
            (this._groupDic[1] as GTileList).dataProvider = this._groupDpDic[1];
            (this._groupDic[2] as GTileList).dataProvider = this._groupDpDic[2];
            (this._groupDic[3] as GTileList).dataProvider = this._groupDpDic[3];
            (this._groupDic[4] as GTileList).dataProvider = this._groupDpDic[4];
            return;
        }

        public updateStartInfo(): void
        {
            var loc2=0;
            var loc1=Cache.instance.robCity.robCityCopyTwoStartInfo;
            if (Cache.instance.robCity.robCityCopyTwoStarted && loc1) 
            {
                this._enterBtn.enabled = true;
                this._countDown.stop();
                this._countDown.htmlText = Language.getString(27028);
                this._tipLabel.htmlText = Language.getStringByParam(60955, loc1.startDt.hours, loc1.startDt.minutes);
            }
            else if (loc1) 
            {
                loc2 = (loc1.startDt.time - ClockManager.instance.nowDate.time) / 1000;
                loc2 = loc2 < 0 ? 0 : loc2;
                this._countDown.setParse(Language.getStringByParam(60941, "hh: mm: ss"));
                this._countDown.setLeftTime(loc2);
                this._enterBtn.enabled = true;
                this._tipLabel.htmlText = Language.getStringByParam(60954, loc1.startDt.hours, loc1.startDt.minutes);
            }
            else 
            {
                this._countDown.stop();
                this._countDown.htmlText = Language.getString(41619);
                this._enterBtn.enabled = false;
                if (Cache.instance.crossCityIncome.getIsDoubleWeek()) 
                {
                    this._tipLabel.htmlText = Language.getString(60940);
                }
                else 
                {
                    this._tipLabel.htmlText = Language.getString(60939);
                }
            }
            return;
        }

        public /* override */ updateStatus(arg1: int): void
        {
            return;
        }

        /* internal */ /* var */_enterBtn: GLoadedButton;

        /* internal */ /* var */_tipLabel: GTextFiled;

        /* internal */ /* var */_countDown: SecTimerView;

        /* internal */ /* var */_groupDic: Map<any, any> /* flash.utils.Dictionary */;

        /* internal */ /* var */_groupDpDic: Map<any, any> /* flash.utils.Dictionary */;
    }
